Component({
  data: {
    src: 'https://leen-1259789579.cos.ap-shanghai.myqcloud.com/wxec7bfe8d55d5465e/product/image/fd9bb16d-32d1-4219-9741-cd4e71d76298.jpg?imageMogr2/thumbnail/335x/interlace/0',
    width: 250, //宽度
    height: 300, //高度
    hidden: true
  },
  ready: function (options) {
    let { src } = this.data
    // 获取到image-cropper实例
    this.cropper = this.selectComponent("#image-cropper");
    wx.showLoading({
      title: '加载中'
    })
  },
  methods: {
    open() {
      this.setData({
        hidden: false
      })
    },
    close() {
      this.setData({
        hidden: true
      })
    },
    cropperload(e){
      console.log("cropper初始化完成");
    },
    loadimage(e){
        console.log("图片加载完成",e.detail);
        wx.hideLoading();
        //重置图片角度、缩放、位置
        this.cropper.imgReset();
    },
    confirm() {
      this.cropper.getImg((e) => {
        this.triggerEvent('confirm', e)
        this.close()
      })
    },
  }
})